package com.ericsson.middleware;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class PropertiesProvider {

	private final static Logger LOGGER = Logger.getLogger(PropertiesProvider.class
			.getName());
	static String PROPERTIES_FILE_NAME = "general.properties";
	static String SUBSCRIPTION_FILE_NAME = "subscription.properties";
	static String EMPTY_STRING = "first";

	static String SESSION_ID_PROVIDER_URL_PROPERTY = "sessionidprovider";
	static String LAMPS_STATUS_PROVIDER_URL_PROPERTY = "lampsstatusprovider";
	static String HEADER_XDREAM_FACTORY_APPLICATION_NAME_PROPERTY = "headerxdreamname";
	static String HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE_PROPERTY = "headerxdreamnamevalue";
	static String HEADER_XDREAM_FACTORY_SESSION_TOKEN_PROPERTY = "headerxdreamsessiontoken";
	static String AUTHENTICATION_EMAIL_PROPERTY = "authenticationemail";
	static String AUTHENTICATION_PASSWORD_PROPERTY = "authenticationpassword";	
	static String PARKING_SPOTS_STATUS_PROVIDER_URL_PROPERTY = "parkingspotsurlprovider";
	static String CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS_PROPERTY = "contextbrokerupdate";
	static String CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS_PROPERTY = "contextbrokersubscribe";
	static String CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS_PROPERTY = "contextBrokerunsubscribe";
	static String MIDDLEWARE_REFERENCE_ADDRESS_PROPERTY = "middlewarereferenceaddress";
	static String UPDATE_REATTEMPTS_PROPERTY = "updatereattempts";
	static String LAMPS_TYPE_PROPERTY = "lampstype";
	static String PARKING_SPOTS_TYPE_PROPERTY = "parkingspottype";
	static String UPDATE_ACTION_UPDATE_PROPERTY = "updateaction";
	static String UPDATE_ACTION_APPEND_PROPERTY = "appendaction";
	static String CONTEXT_BROKER_SUBSCRIBE_DURATION_PROPERTY = "subscribeduration";
	static String CONTEXT_BROKER_SUBSCRIBE_THROTTLING_PROPERTY = "subscribethrottling";
	static String JSON_LAMP_ATTRIBUTES_PROPERTY = "jsonlampattributes";
	static String JSON_PARKINGSPOT_ATTRIBUTES_PROPERTY = "jsonparkingspotattributes";
	static String JSON_LAMP_ATTRIBUTES_TYPE_PROPERTY = "jsonlampattributestype";
	static String JSON_PARKINGSPOT_ATTRIBUTES_TYPE_PROPERTY = "jsonparkingspotattributestype";
	static String ONCHANGE_ATTRIBUTES_TYPE_PROPERTY = "onchangeparams";
	static String ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES_PROPERTY = "onchangesubscriberesponse";



	// lamps
	static String SESSION_ID_PROVIDER_URL;
	static String LAMPS_STATUS_PROVIDER_URL;
	static String HEADER_XDREAM_FACTORY_APPLICATION_NAME;
	static String HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE;
	static String HEADER_XDREAM_FACTORY_SESSION_TOKEN;
	static String AUTHENTICATION_RAW_DATA;

	// parking
	static String PARKING_SPOTS_STATUS_PROVIDER_URL;

	// context broker
	static String CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS;
	static String CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS;
	static String CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS;
	static String MIDDLEWARE_REFERENCE_ADDRESS;
	static String UPDATE_REATTEMPTS;
	static String LAMPS_TYPE;
	static String PARKING_SPOTS_TYPE;	
	static String UPDATE_ACTION_UPDATE;
	static String UPDATE_ACTION_APPEND;
	static String CONTEXT_BROKER_SUBSCRIBE_DURATION;
	static String CONTEXT_BROKER_SUBSCRIBE_THROTTLING;

	// json attributes
	static List<String> JSON_LAMP_ATTRIBUTES = new ArrayList<String>();
	static List<String> JSON_LAMP_ATTRIBUTES_TYPE = new ArrayList<String>();
	static List<String> JSON_PARKINGSPOT_ATTRIBUTES = new ArrayList<String>();
	static List<String> JSON_PARKINGSPOT_ATTRIBUTES_TYPE = new ArrayList<String>();
	static List<String> ONCHANGE_ATTRIBUTES_TYPE = new ArrayList<String>();
	static List<String> ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES = new ArrayList<String>();
	static Map<String,String> JSON_LAMP_ATTRIBUTES_TYPES_MAP = new HashMap<String, String>();
	static Map<String,String> JSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP = new HashMap<String, String>();

	public static List<String> getONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES() {
		return ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES;
	}



	public static void setONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES(
			List<String> oNCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES) {
		ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES = oNCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES;
	}	
	public static String getCONTEXT_BROKER_SUBSCRIBE_DURATION() {
		return CONTEXT_BROKER_SUBSCRIBE_DURATION;
	}



	public static void setCONTEXT_BROKER_SUBSCRIBE_DURATION(
			String cONTEXT_BROKER_SUBSCRIBE_DURATION) {
		CONTEXT_BROKER_SUBSCRIBE_DURATION = cONTEXT_BROKER_SUBSCRIBE_DURATION;
	}



	public static String getCONTEXT_BROKER_SUBSCRIBE_THROTTLING() {
		return CONTEXT_BROKER_SUBSCRIBE_THROTTLING;
	}



	public static void setCONTEXT_BROKER_SUBSCRIBE_THROTTLING(
			String cONTEXT_BROKER_SUBSCRIBE_THROTTLING) {
		CONTEXT_BROKER_SUBSCRIBE_THROTTLING = cONTEXT_BROKER_SUBSCRIBE_THROTTLING;
	}



	public static String getCONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS() {
		return CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS;
	}



	public static void setCONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS(
			String cONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS) {
		CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS = cONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS;
	}

	public static List<String> getONCHANGE_ATTRIBUTES_TYPE() {
		return ONCHANGE_ATTRIBUTES_TYPE;
	}



	public static void setONCHANGE_ATTRIBUTES_TYPE(
			List<String> oNCHANGE_ATTRIBUTES_TYPE) {
		ONCHANGE_ATTRIBUTES_TYPE = oNCHANGE_ATTRIBUTES_TYPE;
	}



	public static String getLAMPS_TYPE() {
		return LAMPS_TYPE;
	}



	public static void setLAMPS_TYPE(String lAMPS_TYPE) {
		LAMPS_TYPE = lAMPS_TYPE;
	}



	public static String getPARKING_SPOTS_TYPE() {
		return PARKING_SPOTS_TYPE;
	}



	public static void setPARKING_SPOTS_TYPE(String pARKING_SPOTS_TYPE) {
		PARKING_SPOTS_TYPE = pARKING_SPOTS_TYPE;
	}



	public static String getUPDATE_ACTION_UPDATE() {
		return UPDATE_ACTION_UPDATE;
	}



	public static void setUPDATE_ACTION_UPDATE(String uPDATE_ACTION_UPDATE) {
		UPDATE_ACTION_UPDATE = uPDATE_ACTION_UPDATE;
	}



	public static String getUPDATE_ACTION_APPEND() {
		return UPDATE_ACTION_APPEND;
	}



	public static void setUPDATE_ACTION_APPEND(String uPDATE_ACTION_APPEND) {
		UPDATE_ACTION_APPEND = uPDATE_ACTION_APPEND;
	}


	public static String getUPDATE_REATTEMPTS() {
		return UPDATE_REATTEMPTS;
	}



	public static void setUPDATE_REATTEMPTS(String uPDATE_REATTEMPTS) {
		UPDATE_REATTEMPTS = uPDATE_REATTEMPTS;
	}



	public static Map<String, String> getJSON_LAMP_ATTRIBUTES_TYPES_MAP() {
		return JSON_LAMP_ATTRIBUTES_TYPES_MAP;
	}



	public static void setJSON_LAMP_ATTRIBUTES_TYPES_MAP(
			Map<String, String> jSON_LAMP_ATTRIBUTES_TYPES_MAP) {
		JSON_LAMP_ATTRIBUTES_TYPES_MAP = jSON_LAMP_ATTRIBUTES_TYPES_MAP;
	}



	public static Map<String, String> getJSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP() {
		return JSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP;
	}



	public static void setJSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP(
			Map<String, String> jSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP) {
		JSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP = jSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP;
	}



	public static List<String> getJSON_LAMP_ATTRIBUTES() {
		return JSON_LAMP_ATTRIBUTES;
	}



	public static void setJSON_LAMP_ATTRIBUTES(List<String> jSON_LAMP_ATTRIBUTES) {
		JSON_LAMP_ATTRIBUTES = jSON_LAMP_ATTRIBUTES;
	}



	public static List<String> getJSON_PARKINGSPOT_ATTRIBUTES() {
		return JSON_PARKINGSPOT_ATTRIBUTES;
	}



	public static void setJSON_PARKINGSPOT_ATTRIBUTES(
			List<String> jSON_PARKINGSPOT_ATTRIBUTES) {
		JSON_PARKINGSPOT_ATTRIBUTES = jSON_PARKINGSPOT_ATTRIBUTES;
	}



	public static String getPARKING_SPOTS_STATUS_PROVIDER_URL() {
		return PARKING_SPOTS_STATUS_PROVIDER_URL;
	}



	public static void setPARKING_SPOTS_STATUS_PROVIDER_URL(
			String pARKING_SPOTS_STATUS_PROVIDER_URL) {
		PARKING_SPOTS_STATUS_PROVIDER_URL = pARKING_SPOTS_STATUS_PROVIDER_URL;
	}



	public static String getCONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS() {
		return CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS;
	}



	public static void setCONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS(
			String cONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS) {
		CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS = cONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS;
	}



	public static String getCONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS() {
		return CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS;
	}



	public static void setCONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS(
			String cONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS) {
		CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS = cONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS;
	}



	public static String getMIDDLEWARE_REFERENCE_ADDRESS() {
		return MIDDLEWARE_REFERENCE_ADDRESS;
	}



	public static void setMIDDLEWARE_REFERENCE_ADDRESS(
			String mIDDLEWARE_REFERENCE_ADDRESS) {
		MIDDLEWARE_REFERENCE_ADDRESS = mIDDLEWARE_REFERENCE_ADDRESS;
	}



	public static String getSESSION_ID_PROVIDER_URL() {
		return SESSION_ID_PROVIDER_URL;
	}



	public static void setSESSION_ID_PROVIDER_URL(String sESSION_ID_PROVIDER_URL) {
		SESSION_ID_PROVIDER_URL = sESSION_ID_PROVIDER_URL;
	}



	public static String getLAMPS_STATUS_PROVIDER_URL() {
		return LAMPS_STATUS_PROVIDER_URL;
	}



	public static void setLAMPS_STATUS_PROVIDER_URL(String lAMPS_STATUS_PROVIDER_URL) {
		LAMPS_STATUS_PROVIDER_URL = lAMPS_STATUS_PROVIDER_URL;
	}



	public static String getHEADER_XDREAM_FACTORY_APPLICATION_NAME() {
		return HEADER_XDREAM_FACTORY_APPLICATION_NAME;
	}



	public static void setHEADER_XDREAM_FACTORY_APPLICATION_NAME(
			String hEADER_XDREAM_FACTORY_APPLICATION_NAME) {
		HEADER_XDREAM_FACTORY_APPLICATION_NAME = hEADER_XDREAM_FACTORY_APPLICATION_NAME;
	}



	public static String getHEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE() {
		return HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE;
	}



	public static void setHEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE(
			String hEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE) {
		HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE = hEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE;
	}



	public static String getHEADER_XDREAM_FACTORY_SESSION_TOKEN() {
		return HEADER_XDREAM_FACTORY_SESSION_TOKEN;
	}



	public static void setHEADER_XDREAM_FACTORY_SESSION_TOKEN(
			String hEADER_XDREAM_FACTORY_SESSION_TOKEN) {
		HEADER_XDREAM_FACTORY_SESSION_TOKEN = hEADER_XDREAM_FACTORY_SESSION_TOKEN;
	}



	public static String getAUTHENTICATION_RAW_DATA() {
		return AUTHENTICATION_RAW_DATA;
	}



	public static void setAUTHENTICATION_RAW_DATA(String aUTHENTICATION_RAW_DATA) {
		AUTHENTICATION_RAW_DATA = aUTHENTICATION_RAW_DATA;
	}







	/**
	 * Load Settings
	 */
	@SuppressWarnings("unchecked")
	public static void loadProperties() {

		LOGGER.log(Level.INFO, "LOADING PROPERTIES: Loading settings from file: " + PROPERTIES_FILE_NAME);
		try {

			PropertiesConfiguration config = new PropertiesConfiguration();
			config.load(PROPERTIES_FILE_NAME);

			// Server URL
			if (config.getProperty(SESSION_ID_PROVIDER_URL_PROPERTY)!=null) {  
				SESSION_ID_PROVIDER_URL = (String) config.getProperty(SESSION_ID_PROVIDER_URL_PROPERTY);
				LOGGER.log(Level.INFO, "get property SESSION_ID_PROVIDER_URL " + SESSION_ID_PROVIDER_URL);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(LAMPS_STATUS_PROVIDER_URL_PROPERTY)!=null) {  
				LAMPS_STATUS_PROVIDER_URL = (String) config.getProperty(LAMPS_STATUS_PROVIDER_URL_PROPERTY);
				LOGGER.log(Level.INFO, "get property LAMPS_STATUS_PROVIDER_URL " + LAMPS_STATUS_PROVIDER_URL);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(HEADER_XDREAM_FACTORY_APPLICATION_NAME_PROPERTY)!=null) {  
				HEADER_XDREAM_FACTORY_APPLICATION_NAME = (String) config.getProperty(HEADER_XDREAM_FACTORY_APPLICATION_NAME_PROPERTY);
				LOGGER.log(Level.INFO, "get property HEADER_XDREAM_FACTORY_APPLICATION_NAME " + HEADER_XDREAM_FACTORY_APPLICATION_NAME);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE_PROPERTY)!=null) {  
				HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE = (String) config.getProperty(HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE_PROPERTY);
				LOGGER.log(Level.INFO, "get property HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE " + HEADER_XDREAM_FACTORY_APPLICATION_NAME_VALUE);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(HEADER_XDREAM_FACTORY_SESSION_TOKEN_PROPERTY)!=null) {  
				HEADER_XDREAM_FACTORY_SESSION_TOKEN = (String) config.getProperty(HEADER_XDREAM_FACTORY_SESSION_TOKEN_PROPERTY);
				LOGGER.log(Level.INFO, "get property HEADER_XDREAM_FACTORY_SESSION_TOKEN " + HEADER_XDREAM_FACTORY_SESSION_TOKEN);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(AUTHENTICATION_EMAIL_PROPERTY)!=null && config.getProperty(AUTHENTICATION_PASSWORD_PROPERTY)!=null ) {  
				AUTHENTICATION_RAW_DATA = "{\"email\":\"" + (String) config.getProperty(AUTHENTICATION_EMAIL_PROPERTY)+ "\", \"password\":\"" + (String) config.getProperty(AUTHENTICATION_PASSWORD_PROPERTY) + "\"}";
				LOGGER.log(Level.INFO, "get property AUTHENTICATION_RAW_DATA " + AUTHENTICATION_RAW_DATA);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}







			if (config.getProperty(PARKING_SPOTS_STATUS_PROVIDER_URL_PROPERTY)!=null) {  
				PARKING_SPOTS_STATUS_PROVIDER_URL = (String) config.getProperty(PARKING_SPOTS_STATUS_PROVIDER_URL_PROPERTY);
				LOGGER.log(Level.INFO, "get property PARKING_SPOTS_STATUS_PROVIDER_URL " + PARKING_SPOTS_STATUS_PROVIDER_URL);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}


			if (config.getProperty(CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS_PROPERTY)!=null) {  
				CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS = (String) config.getProperty(CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS_PROPERTY);
				LOGGER.log(Level.INFO, "get property CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS " + CONTEXT_BROKER_UPDATE_CONTEXT_ADDRESS);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}


			if (config.getProperty(CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS_PROPERTY)!=null) {  
				CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS = (String) config.getProperty(CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS_PROPERTY);
				LOGGER.log(Level.INFO, "get property CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS " + CONTEXT_BROKER_SUBSCRIBE_CONTEXT_ADDRESS);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS_PROPERTY)!=null) {  
				CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS = (String) config.getProperty(CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS_PROPERTY);
				LOGGER.log(Level.INFO, "get property CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS " + CONTEXT_BROKER_UNSUBSCRIBE_CONTEXT_ADDRESS);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(MIDDLEWARE_REFERENCE_ADDRESS_PROPERTY)!=null) {  
				MIDDLEWARE_REFERENCE_ADDRESS = (String) config.getProperty(MIDDLEWARE_REFERENCE_ADDRESS_PROPERTY);
				LOGGER.log(Level.INFO, "get property MIDDLEWARE_REFERENCE_ADDRESS " + MIDDLEWARE_REFERENCE_ADDRESS);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(UPDATE_REATTEMPTS_PROPERTY)!=null) {  
				UPDATE_REATTEMPTS = (String) config.getProperty(UPDATE_REATTEMPTS_PROPERTY);
				LOGGER.log(Level.INFO, "get property UPDATE_REATTEMPTS " + UPDATE_REATTEMPTS);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(LAMPS_TYPE_PROPERTY)!=null) {  
				LAMPS_TYPE = (String) config.getProperty(LAMPS_TYPE_PROPERTY);
				LOGGER.log(Level.INFO, "get property LAMPS_TYPE " + LAMPS_TYPE);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(PARKING_SPOTS_TYPE_PROPERTY)!=null) {  
				PARKING_SPOTS_TYPE = (String) config.getProperty(PARKING_SPOTS_TYPE_PROPERTY);
				LOGGER.log(Level.INFO, "get property PARKING_SPOTS_TYPE " + PARKING_SPOTS_TYPE);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(UPDATE_ACTION_UPDATE_PROPERTY)!=null) {  
				UPDATE_ACTION_UPDATE = (String) config.getProperty(UPDATE_ACTION_UPDATE_PROPERTY);
				LOGGER.log(Level.INFO, "get property UPDATE_ACTION_UPDATE " + UPDATE_ACTION_UPDATE);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(UPDATE_ACTION_APPEND_PROPERTY)!=null) {  
				UPDATE_ACTION_APPEND = (String) config.getProperty(UPDATE_ACTION_APPEND_PROPERTY);
				LOGGER.log(Level.INFO, "get property UPDATE_ACTION_APPEND " + UPDATE_ACTION_APPEND);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(CONTEXT_BROKER_SUBSCRIBE_DURATION_PROPERTY)!=null) {  
				CONTEXT_BROKER_SUBSCRIBE_DURATION = (String) config.getProperty(CONTEXT_BROKER_SUBSCRIBE_DURATION_PROPERTY);
				LOGGER.log(Level.INFO, "get property CONTEXT_BROKER_SUBSCRIBE_DURATION " + CONTEXT_BROKER_SUBSCRIBE_DURATION);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(CONTEXT_BROKER_SUBSCRIBE_THROTTLING_PROPERTY)!=null) {  
				CONTEXT_BROKER_SUBSCRIBE_THROTTLING = (String) config.getProperty(CONTEXT_BROKER_SUBSCRIBE_THROTTLING_PROPERTY);
				LOGGER.log(Level.INFO, "get property CONTEXT_BROKER_SUBSCRIBE_THROTTLING " + CONTEXT_BROKER_SUBSCRIBE_THROTTLING);
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(JSON_LAMP_ATTRIBUTES_PROPERTY)!=null) { 
				JSON_LAMP_ATTRIBUTES =  (List<String>) config.getProperty(JSON_LAMP_ATTRIBUTES_PROPERTY);
				for (String temp : JSON_LAMP_ATTRIBUTES) {
					LOGGER.log(Level.INFO, "get attr Lamp: " + temp);
				}
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(JSON_PARKINGSPOT_ATTRIBUTES_PROPERTY)!=null) { 
				JSON_PARKINGSPOT_ATTRIBUTES =  (List<String>) config.getProperty(JSON_PARKINGSPOT_ATTRIBUTES_PROPERTY);
				for (String temp : JSON_PARKINGSPOT_ATTRIBUTES) {
					LOGGER.log(Level.INFO, "get attr Parking Spot: " + temp);
				}
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(JSON_LAMP_ATTRIBUTES_TYPE_PROPERTY)!=null) { 
				JSON_LAMP_ATTRIBUTES_TYPE =  (List<String>) config.getProperty(JSON_LAMP_ATTRIBUTES_TYPE_PROPERTY);
				for (String temp : JSON_LAMP_ATTRIBUTES_TYPE) {
					LOGGER.log(Level.INFO, "get attr type Lamp: " + temp);
				}
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(JSON_PARKINGSPOT_ATTRIBUTES_TYPE_PROPERTY)!=null) { 
				JSON_PARKINGSPOT_ATTRIBUTES_TYPE =  (List<String>) config.getProperty(JSON_PARKINGSPOT_ATTRIBUTES_TYPE_PROPERTY);
				for (String temp : JSON_PARKINGSPOT_ATTRIBUTES_TYPE) {
					LOGGER.log(Level.INFO, "get attr type Parking Spot: " + temp);
				}
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

			if (config.getProperty(ONCHANGE_ATTRIBUTES_TYPE_PROPERTY)!=null) { 
				ONCHANGE_ATTRIBUTES_TYPE =  (List<String>) config.getProperty(ONCHANGE_ATTRIBUTES_TYPE_PROPERTY);
				for (String temp : ONCHANGE_ATTRIBUTES_TYPE) {
					LOGGER.log(Level.INFO, "get attr type on change: " + temp);
				}
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}
			
			if (config.getProperty(ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES_PROPERTY)!=null) { 
				ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES =  (List<String>) config.getProperty(ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES_PROPERTY);
				for (String temp : ONCHANGE_SUBSCRIBE_RESPONSE_ATTRIBUTES) {
					LOGGER.log(Level.INFO, "get attr type on change: " + temp);
				}
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}


			for (int i = 0; i < JSON_LAMP_ATTRIBUTES_TYPE.size(); i++) {
				JSON_LAMP_ATTRIBUTES_TYPES_MAP.put(JSON_LAMP_ATTRIBUTES.get(i), JSON_LAMP_ATTRIBUTES_TYPE.get(i));
			}
			for (int i = 0; i < JSON_PARKINGSPOT_ATTRIBUTES_TYPE.size(); i++) {
				JSON_PARKINGSPOT_ATTRIBUTES_TYPES_MAP.put(JSON_PARKINGSPOT_ATTRIBUTES.get(i), JSON_PARKINGSPOT_ATTRIBUTES_TYPE.get(i));
			}




		} catch (Exception ex) {
			LOGGER.log(Level.SEVERE, "loadProperties: *** Unable to load " + PROPERTIES_FILE_NAME + ": " + ex.getMessage());
		}



	}

	public static void setSubscriptionIdProperty(List<String> subscriptiodIds) {
		PropertiesConfiguration config = new PropertiesConfiguration();
		try {
			subscriptiodIds.remove("");
			if (subscriptiodIds.isEmpty()){
				subscriptiodIds.add(EMPTY_STRING);
			}
			if (subscriptiodIds.size() == 1) {
				subscriptiodIds.add(""); // need to add empty string to set as list in the file
			}
			config.load(SUBSCRIPTION_FILE_NAME);
			config.setProperty("subscriptionid", subscriptiodIds);
			File save = config.getFile();
			config.setFile(save);
			config.save();
		} catch (ConfigurationException ex) {
			LOGGER.log(Level.SEVERE, "loadProperties: *** Unable to set subscriptionid: "  + ex.getMessage());
		}
	}

	public static List<String> getSubscriptionIdProperty() {
		PropertiesConfiguration config = new PropertiesConfiguration();
		try {
			config.load(SUBSCRIPTION_FILE_NAME);
			List<String> subscriptionids = new ArrayList<String>();
			subscriptionids = (List<String>) config.getProperty("subscriptionid");
			if (subscriptionids != null) { 
				subscriptionids.remove(""); // empty string does not interest
				subscriptionids.remove(EMPTY_STRING);
				for (String subscriptionid : subscriptionids) {
					LOGGER.log(Level.INFO, "get subscriptionid: " + subscriptionid);
				}
				return subscriptionids;
			} else {
				LOGGER.log(Level.SEVERE, "get property failed");
			}

		} catch (ConfigurationException ex) {
			LOGGER.log(Level.SEVERE, "loadProperties: *** Unable to load " + SUBSCRIPTION_FILE_NAME + ": " + ex.getMessage());
		}
		return null;
	}
}
